package com.sec.android.app.myfiles.module.download.cmd;

import com.sec.android.app.myfiles.facade.MyFilesFacade;
import com.sec.android.app.myfiles.facade.cmd.DeleteRecordCmd;
import com.sec.android.app.myfiles.fragment.AbsMyFilesFragment;
import com.sec.android.app.myfiles.module.abstraction.FileRecord;

import org.puremvc.java.multicore.interfaces.INotification;
import org.puremvc.java.multicore.patterns.command.SimpleCommand;

import java.util.ArrayList;

public class ClearHistoryCmd extends SimpleCommand {

    @Override
    public void execute(INotification notification) {
        Object[] params = (Object[]) notification.getBody();

        AbsMyFilesFragment fragment = (AbsMyFilesFragment) params[0];
        ArrayList<FileRecord> recordList = new ArrayList<>();
        int size = fragment.getListItemCount();
        for (int i = 0; i < size; i++) {
            recordList.add(fragment.getFileRecord(i));
        }
        MyFilesFacade.deleteRecord(fragment.getProcessId(), fragment.context(), fragment, recordList, DeleteRecordCmd.OperationProgress.DO_OPERATE);
    }
}
